#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <limits.h>
int main()
{
	int n, m, min = INT_MAX, max = INT_MIN, a[1001] = { 0 };
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		a[m] += 1;  //记录某个数字出现的次数

		if (m < min)
			min = m;
		if (m > max)
			max = m;
	}

	printf("%d %d\n", min, a[min]);
	printf("%d %d\n", max, a[max]);
	return 0;
}